-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Theme: Inline values for primitive tokens in CSS output #72890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -8.5 kB (-0.35%) Total Size: 2.41 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 9b888e1. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19270841406
|
2ada354 to
9128c16
Compare
|
@jsnajdr With what you're exploring in #73004 (comment) about limiting which colors we generate, I wonder if anything here could potentially lend to similar optimizations? What I like about this approach is that the |
Every color generated in a ramp is used for two purposes:
Should even an unused color trigger seed adjustments? There are two possible answers:
|
jsnajdr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally took this PR for a test drive and it looks good, let's merge it ![]()
1993b8a to
9b888e1
Compare
What?
Builds on #72305
Updates theme package to avoid emitting CSS properties for primitive design tokens.
Why?
packages/theme/src/prebuilt/css/design-tokens.css)useThemeProviderStylesHow?
For compile-time build, the changes include a new Terrazzo plugin that match a given token ID by RegExp pattern and inline its value to anywhere that token ID is referenced as an alias (i.e. semantic tokens).
The runtime theming is a bit more challenging, since we relied on this aliasing to allow us to override primitive CSS properties and allow those changes to cascade to any semantic CSS properties. To maintain this behavior, the plugin emits a mapping of matched tokens to tokens which alias it, so that the runtime theme provider can override the semantic CSS properties associated with the color ramp (primitive) tokens.
This is what could also enable further performance enhancements, since using a file like this could allow us to generate color ramps based exclusively on primitive values which are actually referenced by a semantic token.
Testing Instructions
Validate no regressions in behavior of behavior of theme provider:
npm run storybook:startVerify that building theme package succeeds and produces no local changes:
npm run --workspace @wordpress/theme buildgit status